<template>
	<view>
		<view class="tabBar">
			<view class="item" v-for="(item, index) in list" :key="index" @click="handleTab(item.pagePath)">
				<u-icon size="20" :name="current == item.index ? item.selectedIconPath : item.iconPath"></u-icon>
				<text :class="current == item.index ? 'action' : ''">{{ getStr('menu.' + item.text) }}</text>
			</view>
		</view>
		<!-- <view style="height:180rpx"></view> -->
	</view>
</template>

<script>
	import {
		mapState,
		mapActions
	} from 'vuex'
	import nav1 from '@/static/images1/index/userImg.png'
	import nav01 from '@/static/images1/index/userImg.png'
	import nav2 from '@/static/images1/index/userImg.png'
	import nav02 from '@/static/images1/index/userImg.png'

	export default {
		props: {
			current: {
				type: Number,
				default: 0
			}
		},
		data() {
			return {
				list: [{
						"pagePath": "/pages/index/index",
						"iconPath": "/static/images1/nav/nav1.png",
						"selectedIconPath": "/static/images1/nav/nav01.png",
						"text": "home",
						"index": 0
					},
					{
						"pagePath": "/pages/starPond/index",
						"iconPath": "/static/images1/nav/nav2.png",
						"selectedIconPath": "/static/images1/nav/nav02.png",
						"text": "starPond",
						"index": 1
					},
					{
						"pagePath": "/pages/swap/index",
						"iconPath": "/static/images1/nav/nav3.png",
						"selectedIconPath": "/static/images1/nav/nav03.png",
						"text": "swap",
						"index": 2
					},
					{
						"pagePath": "/pages/trade/index",
						"iconPath": "/static/images1/nav/nav4.png",
						"selectedIconPath": "/static/images1/nav/nav04.png",
						"text": "trade",
						"index": 3
					},
					{
						"pagePath": "/pages/my/index",
						"iconPath": "/static/images1/nav/nav5.png",
						"selectedIconPath": "/static/images1/nav/nav05.png",
						"text": "assets",
						"index": 4
					}
				],
				isRender: true
			}
		},
		beforeMount() {
			uni.hideTabBar(false)
			this.setIsRender()
		},
		methods: {
			handleTab(url) {
				uni.switchTab({
					url: url
				})
			},
			getStr(key) {
				return uni.$t(key)
			},
			setIsRender() {
				this.isRender = false
				setTimeout(() => {
					this.isRender = true
				}, 50)
			}
		}
	}
</script>

<style lang="scss">
	.tabBar {
		position: fixed;
		bottom: 0;
		// padding-bottom: constant(safe-area-inset-bottom);
		// padding-bottom: env(safe-area-inset-bottom);
		padding-bottom: 6px;
		box-sizing: content-box;
		left: 0;
		z-index: 99;
		width: 100%;
		height: 90rpx;
		background-color: #272A2E;
		display: flex;
		justify-content: space-between;
	}

	.tabBar .item {
		width: 20%;
		text-align: center;
		font-size: 20rpx;
		color: #999999;
		padding-top: 8rpx;
		display: flex;
		flex-direction: column;
		align-items: center;

		text {
			display: block;
			margin-top: 5rpx;
		}

		.action {
			color: #ffffff;
		}
	}
</style>